Two mechanisms which have been widely used to implement memory allocation functions in computer systems are pointers and handles. A pointer is a variable which has a value representing an address of data rather than the data itself. Pointers are useful in allowing memory to be dynamically allocated and deallocated. Programming languages, software development tools, library code, and documentation are frequently based upon the assumption that the system will make use of the pointer abstraction. One problem with the use of pointers, however, is that it can result in fragmentation of stored data as memory locations are allocated and deallocated. Fragmentation results in the inefficient use of memory space. Note that fragmentation can occur in a system regardless of whether the system has a memory management unit.
Handles represent one solution to the problem of fragmentation. A handle is essentially a pointer to a pointer. Thus, the use of handles adds a level of indirection to the referencing of stored data as compared to the use of pointers. The handles technique eliminates the fragmentation problem, because the system can change the pointers without effecting the handles. The handles approach therefore allows memory to be allocated dynamically.
Although handles eliminate memory fragmentation, they also tend to require more computer program code than pointers. In addition, such code also tends to be less efficient and less robust than that associated with pointers. Also, because memory is required not only for the pointer itself but also for its handle, the handles approach tends to require more memory space than is desirable.
Hence, what is needed is a technique which will allow memory allocation with the ability to reduce fragmentation, which is well-suited to implementation in robust and efficient computer program code. In particular, it is desirable to have a solution which has the robustness and efficiency associated with pointers combined with the fragmentation management delivered via handles.